HTMLify
style.css
Views: 22 | Author: huxn-webdev
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | :root { --primary-color: white; --primary-label: black; --secndary-label: white; --white-ball: white; --black-ball: black; } body { background: var(--primary-color); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); } #switch { width: 0; height: 0; visibility: hidden; } label { display: block; width: 100px; height: 50px; background: var(--primary-label); border-radius: 100px; position: relative; cursor: pointer; transition: 0.5s; } label::after { content: ""; width: 40px; height: 40px; border-radius: 70px; background-color: var(--white-ball); position: absolute; top: 5px; left: 5px; transition: 0.5s; } #switch:checked + label:after { background-color: var(--black-ball); left: calc(100% - 5px); transform: translateX(-100%); } #switch:checked + label { background-color: var(--secndary-label); } label:active:after { width: 60px; } |